<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Letter extends Model
{

    protected $primaryKey="letter_id";

    protected $fillable=[
      'title','content','to','status','send_time','scope','user_id'
    ];

    public static function PostLetter(array $attrbute){
        $letter = static::create($attrbute);
        return $letter;
    }

    public function user()
    {
        return $this->hasOne(User::class,'user_id','user_id');
    }

    public function comments()
    {
        return $this->hasMany(Comment::class);
    }
}
